import store from '../store'
function renderTypeCloum(value) {
  if (value === "0") {
    return "货物";
  }
  if (value === "1") {
    return "服务";
  }
}
function isShouldPostOfficeCode() {
  if (store.state.user.userInfo.roleCode === 'sjbm_ld' || store.state.user.userInfo.roleCode === 'sjbm' ||
    store.state.user.userInfo.roleCode === 'jbbm1' || store.state.user.userInfo.roleCode === 'jld') {
    return false;
  }
  return true;
}
export function isShouldPostOfficeCodeNew() {
  if (store.state.user.userInfo.roleCode === 'sjbm_ld' || store.state.user.userInfo.roleCode === 'sjbm' ||
    store.state.user.userInfo.roleCode === 'jbbm1' || store.state.user.userInfo.roleCode === 'jld') {

    return false;
  }

  return true;
}
function commonOpenAdmin() {

}

export function fontSizeByEchart(res) {
  const clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  if (!clientWidth) return;
  let fontSize = clientWidth / 1920;
  return res * fontSize;
}
function getDictNameByValue(dictList, value,dictName='name',dictValue='value') {
  for (let item of dictList) {
    if (item[dictValue] === value) {
      return item[dictName];
    }
  }
  return value;
}
function getJd(row) {
  var jd = '<div class="xmjdRow">';
  if (row.ysAS != '' && row.ysAS != null && row.ysAS && row.ysAS != undefined) {
    if (row.ysAS != '6') {
      // jd+='<div class="xmjdClo" style="height: 15px;width:30px;background-color: #f9b851;border:1px solid #FFFFFF;">&nbsp;</div>';
      jd += ysjd(row.ysAS);
    } else {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #009900;border:1px solid #FFFFFF;">&nbsp;</div>';
    }
  } else {
    // console.log("22222------"+row.projectName+row.ysAS)
    if (row.ysAS == null) {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #666666;border:1px solid #FFFFFF">&nbsp;</div>';

    }
  }
  if (row.dqAS != '' && row.dqAS != null && row.dqAS && row.dqAS != undefined && row.dqAS != '0' && row.dqAS != '1' && row.dqAS != '11') {
    if (row.dqAS != '6') {
      // jd+='<div class="xmjdClo" style="height: 15px;width:30px;background-color: #f9b851;border:1px solid #FFFFFF">&nbsp;</div>';
      jd += ysjd(row.dqAS);
    } else {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #009900;border:1px solid #FFFFFF">&nbsp;</div>';
    }
  } else {
    if (row.ysAS == null && row.jsAS != null) {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #666666;border:1px solid #FFFFFF">&nbsp;</div>';
    } else if (row.ysIsSecretRelated == '1') {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #666666;border:1px solid #FFFFFF">&nbsp;</div>';

    } else {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #FF0000;border:1px solid #FFFFFF">&nbsp;</div>';
    }
  }
  if (row.jsAS != '' && row.jsAS != null && row.jsAS && row.jsAS != undefined && row.jsAS != '0' && row.jsAS != '1' && row.jsAS != '11') {
    if (row.jsAS != '6' &&row.jsAS) {
      // jd+='<div class="xmjdClo" style="height: 15px;width:30px;background-color: #f9b851;border:1px solid #FFFFFF;">&nbsp;</div>';
      jd += ysjd(row.jsAS);
    } else {
      jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #009900;border:1px solid #FFFFFF;">&nbsp;</div>';
    }
  } else if (row.ysIsSecretRelated == '1') {
    jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #666666;border:1px solid #FFFFFF">&nbsp;</div>';

  } else {
    jd += '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #FF0000;border:1px solid #FFFFFF;">&nbsp;</div>';
  }
  jd += '</div>';
  return jd;
}

function ysjd(auditStatus) {
  if (auditStatus == "2") {
    return '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #FFCC00;border:1px solid #FFFFFF;">&nbsp;</div>';
  } else if (auditStatus == "4") {
    return '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #66CCCC;border:1px solid #FFFFFF;">&nbsp;</div>';
  } else if (auditStatus == "5" || auditStatus == "7") {
    return '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #00CCFF;border:1px solid #FFFFFF;">&nbsp;</div>';
  } else if (auditStatus == "3" || auditStatus == "10" || auditStatus == "13" || auditStatus == "14" || auditStatus == "18" || auditStatus == "19" || auditStatus == "17" || auditStatus == "16") {
    return '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #009999;border:1px solid #FFFFFF;">&nbsp;</div>';
  } else if (auditStatus == "6") {
    return '<div class="xmjdClo" style="height: 15px;width:30px;background-color: #009900;border:1px solid #FFFFFF;">&nbsp;</div>';
  }
  return '';
};
export default {
  renderTypeCloum,
  isShouldPostOfficeCode,
  getDictNameByValue,
  getJd,
  ysjd
}